package com.zj.fx.service.info;

import java.util.List;
import java.util.Arrays;

import com.zj.fx.mapper.info.InfoWeburlMapper;
import com.zj.fx.model.info.InfoSubcompany;
import com.zj.fx.model.info.InfoSubcompanyExample;
import com.zj.fx.model.info.InfoWeburl;
import com.zj.fx.model.info.InfoWeburlExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import cn.hutool.core.util.StrUtil;
import com.zj.fx.common.base.BaseService;
import com.zj.fx.common.support.ConvertUtil;
import com.zj.fx.model.custom.Tablepar;
import com.zj.fx.util.SnowflakeIdWorker;
import com.zj.fx.util.StringUtils;

/**
 * 填报说明文档相关网站地址 InfoWeburlService
 * @Title: InfoWeburlService.java 
 * @Package com.zj.fx.service 
 * @author SQL_自动生成
 * @email ${email}
 * @date 2023-07-07 09:28:01  
 **/
@Service
public class InfoWeburlService implements BaseService<InfoWeburl, InfoWeburlExample> {
    @Autowired
    private InfoWeburlMapper infoWeburlMapper;

                                                                                        
    /**
     * 分页查询
     * @param
     * @param
     * @return
     */
    public PageInfo<InfoWeburl> list(Tablepar tablepar,InfoWeburl infoWeburl) {
            InfoWeburlExample testExample = new InfoWeburlExample();
        //搜索
        if (StrUtil.isNotEmpty(tablepar.getSearchText())) {//小窗体
            testExample.createCriteria().andLikeQuery2(tablepar.getSearchText());
        } else {//大搜索
            testExample.createCriteria().andLikeQuery(infoWeburl);
        }
        //表格排序
        //if(StrUtil.isNotEmpty(tablepar.getOrderByColumn())) {
        //	testExample.setOrderByClause(StringUtils.toUnderScoreCase(tablepar.getOrderByColumn()) +" "+tablepar.getIsAsc());
        //}else{
        //	testExample.setOrderByClause("id ASC");
        //}
        PageHelper.startPage(tablepar.getPage(), tablepar.getLimit());
        List<InfoWeburl> list = infoWeburlMapper.selectByExample(testExample);
        PageInfo<InfoWeburl> pageInfo = new PageInfo<InfoWeburl>(list);
        return pageInfo;
    }
    
        @Override
        public int deleteByPrimaryKey(String ids) {
            
                List<String> lista = ConvertUtil.toListStrArray(ids);
                    InfoWeburlExample example = new InfoWeburlExample();
                example.createCriteria().andIdIn(lista);
                return infoWeburlMapper.deleteByExample(example);

            
        }


        @Override
        public InfoWeburl selectByPrimaryKey(String id) {
            
                return infoWeburlMapper.selectByPrimaryKey(id);
            
        }


        @Override
        public int updateByPrimaryKeySelective(InfoWeburl record) {
            return infoWeburlMapper.updateByPrimaryKeySelective(record);
        }

    
    /**
     * 添加
     */
    @Override
    public int insertSelective(InfoWeburl record) {
        
            //添加雪花主键id
            record.setId(SnowflakeIdWorker.getUUID());

        
        return infoWeburlMapper.insertSelective(record);
    }


    @Override
    public int updateByExampleSelective(InfoWeburl record, InfoWeburlExample example) {

        return infoWeburlMapper.updateByExampleSelective(record, example);
    }


    @Override
    public int updateByExample(InfoWeburl record, InfoWeburlExample example) {

        return infoWeburlMapper.updateByExample(record, example);
    }

    @Override
    public List<InfoWeburl> selectByExample(InfoWeburlExample example) {

        return infoWeburlMapper.selectByExample(example);
    }


    @Override
    public long countByExample(InfoWeburlExample example) {

        return infoWeburlMapper.countByExample(example);
    }


    @Override
    public int deleteByExample(InfoWeburlExample example) {

        return infoWeburlMapper.deleteByExample(example);
    }


    public int checkOrderUnique(InfoWeburl infoWeburl) {
        InfoWeburlExample infoWeburlExample = new InfoWeburlExample();
        infoWeburlExample.createCriteria().andOrdernumEqualTo(infoWeburl.getOrdernum());
        return infoWeburlMapper.selectByExample(infoWeburlExample).size();
    }

}
